<template>
  <div>
    <el-breadcrumb separator-class="el-icon-arrow-right">
      <el-breadcrumb-item :to="{ path: '/home' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item>用户管理</el-breadcrumb-item>
      <el-breadcrumb-item>视频管理</el-breadcrumb-item>
      <el-breadcrumb-item>角色管理</el-breadcrumb-item>
    </el-breadcrumb>

    <el-card>
      <el-row>
        <el-col>
          <el-button type="primary">添加角色</el-button>
        </el-col>
      </el-row>
      <!-- 角色列表区 -->
      <el-table :data='rolelist' border stripe>
        <!-- 展开列 -->
        <el-table-column type="expand"></el-table-column>

        <el-table-column type="index"></el-table-column>
        <el-table-column label="角色名称" prop="roleName"></el-table-column>
        <el-table-column label="角色描述" prop="roleDesc"></el-table-column>
        <el-table-column label="操作" width="300px">
          <template slot="scope">
            <el-button size="min" type="primary" icon="el-icon-edit">编辑</el-button>
            <el-button size="min" type="danger" icon="el-icon-delete">删除</el-button>
            <el-button size="min" type="warning" icon="el-icon-setting">分配权限</el-button>
          </template>
        </el-table-column>
      </el-table>
    </el-card>
  </div>
</template>

<script>
export default {
  name:'Roles',
  data(){//获取数据请求
    return{
      //所有角色列表数据
      rolelist:[]
    }
  },
  created(){
    this.getRolesList()
  },
  methods:{
    //获取所有角色列表的数据
    async getRolesList(){
      const {data:res} = await this.$http.get('roles')
      if(res.meta.status !==200){
        return this.$message.error('获取角色列表失败')
      }
      this.rolelist = res.data
    }
  }
}
</script>

<style scoped>
  .el-table{
    margin-top: 15px;
  }
</style>